package 笔试题.yingtailai;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class 母羊问题 {
    public static void main(String[] args) {
        int id = 0;
        Map<Integer, Integer> map = new ConcurrentHashMap<>();
        map.put(++id, 0);
        for (int i = 0; i < 15; i++) {
            int increase = 0;
            List<Integer> del = new ArrayList<>();
            for (Integer integer : map.keySet()) {
                int newAge = map.get(integer) + 1;
                map.put(integer, newAge);
                if (newAge == 2 || newAge == 4) increase++;
                if (newAge == 5) del.add(integer);
            }
            for (Integer integer : del) {
                map.remove(integer);
            }
            for (int j = 0; j < increase; j++) {
                map.put(++id, 0);
            }
        }
        System.out.println(map.keySet().size());
    }
}
